package jangdolbaeng2.admin.action;

import jangdolbaeng2.admin.dao.OrderDao;
import jangdolbaeng2.tools.ClobToString;
import jangdolbaeng2.vo.DeliveryVO;
import jangdolbaeng2.vo.ProductVO;
import jangdolbaeng2.vo.Product_orderVO;







import java.util.HashMap;
import java.util.List;

import oracle.sql.CLOB;

import com.opensymphony.xwork2.ActionSupport;

public class OrderAction extends ActionSupport {
	
	private List<Product_orderVO> orderList;
	private int order_seq;
	
	private List<HashMap<String, Object>> order_detailList;
	private HashMap<String, Object> delivery;
	
	private int product_seq;
	private HashMap<String, Object> product;
	
	private int orderDay = 1;
	
	private char type;
	
	private String id;
	
	/*
	 * 작성자: 박성곤 작성일: 20141014
	 * 기능: 주문리스트 불러오기
	 */
	public String orderList() {
		System.out.println("DeliveryAction.orderList()> orderDay: " + orderDay);
		
		orderList = new OrderDao().orderList(orderDay);
		
		return SUCCESS;
	}//orderList()

	
	/*
	 * 작성자: 박성곤 작성일: 20141015
	 * 기능: 주문상세정보
	 */
	public String orderDetail() {
		System.out.println("DeliveryAction.orderDetail()> order_seq: " + order_seq);
		
		order_detailList = new OrderDao().orderDetail(order_seq);
		delivery = new OrderDao().delivery(order_seq);
		
		return SUCCESS;
	}//orderList()
	
	public String delivery_go() {
		System.out.println("DeliveryAction.delivery_go()> order_seq: " + order_seq);
		
		new OrderDao().delivery_go(order_seq);		
		return this.orderList();
	}//delivery_go()
	
	public String delivery_cancel() {
		System.out.println("DeliveryAction.delivery_cancel()> order_seq: " + order_seq);
		
		new OrderDao().delivery_cancel(order_seq);		
		return this.orderList();
	}//delivery_go()
	
	public String productDetail() {
		System.out.println("DeliveryAction.productDetail()> product_seq: " + product_seq);
		
		product = new OrderDao().productDetail(product_seq);
		
		product.put("PRODUCT_IMAGE1", ClobToString.change((CLOB) product.get("PRODUCT_IMAGE1")));
		product.put("PRODUCT_IMAGE2", ClobToString.change((CLOB) product.get("PRODUCT_IMAGE2")));
		
		return SUCCESS;
	}//productDetail()
	
	public String deliveryComplete() {
		System.out.println("DeliveryAction.deliveryComplete()> order_seq: " + order_seq);
		new OrderDao().deliveryComplete(order_seq);	
		
		return this.orderDetail();
	}//deliveryComplete()
	
		
	/*
	 * 새로추가할 기능
	 */
	
	public String orderSort() {
		System.out.println("DeliveryAction.orderSort()> type: " + type);
		orderList = new OrderDao().orderSort(type);	
		
		return SUCCESS;
	}//orderSort()
	
	public String orderSortbyId() {
		System.out.println("DeliveryAction.orderSortbyId()> id: " + id);
		orderList = new OrderDao().orderSortbyId(id);	
		
		return SUCCESS;
	}//orderSort()
	
	
	public String orderPrepared() {
		System.out.println("DeliveryAction.orderPrepared()> order_seq: " + order_seq + " product_seq: " + product_seq);
		new OrderDao().orderPrepared(order_seq, product_seq);	
		
		return this.orderDetail();
	}//orderPrepared()
	
	public String orderNotPrepared() {
		System.out.println("DeliveryAction.orderNotPrepared()> order_seq: " + order_seq + " product_seq: " + product_seq);
		new OrderDao().orderNotPrepared(order_seq, product_seq);	
		
		return this.orderDetail();
	}//orderNotPrepared()
		
	/*
	 * getters and setters
	 */
	
	public List<Product_orderVO> getOrderList() {
		return orderList;
	}

	public void setOrderList(List<Product_orderVO> orderList) {
		this.orderList = orderList;
	}	
	
	public int getOrder_seq() {
		return order_seq;
	}

	public void setOrder_seq(int order_seq) {
		this.order_seq = order_seq;
	}


	public List<HashMap<String, Object>> getOrder_detailList() {
		return order_detailList;
	}
	
	public void setOrder_detailList(List<HashMap<String, Object>> order_detailList) {
		this.order_detailList = order_detailList;
	}	

	public HashMap<String, Object> getDelivery() {
		return delivery;
	}

	public void setDelivery(HashMap<String, Object> delivery) {
		this.delivery = delivery;
	}	
	
	public int getProduct_seq() {
		return product_seq;
	}


	public void setProduct_seq(int product_seq) {
		this.product_seq = product_seq;
	}

	public HashMap<String, Object> getProduct() {
		return product;
	}
	
	public void setProduct(HashMap<String, Object> product) {
		this.product = product;
	}

	public int getOrderDay() {
		return orderDay;
	}

	public void setOrderDay(int orderDay) {
		this.orderDay = orderDay;
	}

	public char getType() {
		return type;
	}

	public void setType(char type) {
		this.type = type;
	}

	public String getId() {
		return id;	}


	public void setId(String id) {
		this.id = id;
	}		
	
	
}//class
